package com.ruoyi.web.controller.comment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.comment.domain.CommerceInfoComment;
import com.ruoyi.comment.service.ICommerceInfoCommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 帮养之家和评论关联Controller
 *
 * @author zhezhi
 * @date 2022-10-05
 */
@RestController
@RequestMapping("/commerce/commentInfo")
public class CommerceInfoCommentController extends BaseController
{
    @Autowired
    private ICommerceInfoCommentService commerceInfoCommentService;

    /**
     * 查询帮养之家和评论关联列表
     */
    @PreAuthorize("@ss.hasPermi('commerce:commentInfo:list')")
    @GetMapping("/list")
    @ApiOperation("查询帮养之家和评论关联列表")
    public TableDataInfo list(CommerceInfoComment commerceInfoComment)
    {
        startPage();
        List<CommerceInfoComment> list = commerceInfoCommentService.selectCommerceInfoCommentList(commerceInfoComment);
        return getDataTable(list);
    }

    /**
     * 导出帮养之家和评论关联列表
     */
    @PreAuthorize("@ss.hasPermi('commerce:commentInfo:export')")
    @Log(title = "帮养之家和评论关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出帮养之家和评论关联列表")
    public void export(HttpServletResponse response, CommerceInfoComment commerceInfoComment)
    {
        List<CommerceInfoComment> list = commerceInfoCommentService.selectCommerceInfoCommentList(commerceInfoComment);
        ExcelUtil<CommerceInfoComment> util = new ExcelUtil<CommerceInfoComment>(CommerceInfoComment.class);
        util.exportExcel(response, list, "帮养之家和评论关联数据");
    }

    /**
     * 获取帮养之家和评论关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('commerce:commentInfo:query')")
    @GetMapping(value = "/{commerceId}")
    @ApiOperation("获取帮养之家和评论关联详细信息")
    public AjaxResult getInfo(@PathVariable("commerceId") Long commerceId)
    {
        return AjaxResult.success(commerceInfoCommentService.selectCommerceInfoCommentByCommerceId(commerceId));
    }

    /**
     * 新增帮养之家和评论关联
     */
    @PreAuthorize("@ss.hasPermi('commerce:commentInfo:add')")
    @Log(title = "帮养之家和评论关联", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增帮养之家和评论关联")
    public AjaxResult add(@RequestBody CommerceInfoComment commerceInfoComment)
    {
        return toAjax(commerceInfoCommentService.insertCommerceInfoComment(commerceInfoComment));
    }

    /**
     * 修改帮养之家和评论关联
     */
    @PreAuthorize("@ss.hasPermi('commerce:commentInfo:edit')")
    @Log(title = "帮养之家和评论关联", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改帮养之家和评论关联")
    public AjaxResult edit(@RequestBody CommerceInfoComment commerceInfoComment)
    {
        return toAjax(commerceInfoCommentService.updateCommerceInfoComment(commerceInfoComment));
    }

    /**
     * 删除帮养之家和评论关联
     */
    @PreAuthorize("@ss.hasPermi('commerce:commentInfo:remove')")
    @Log(title = "帮养之家和评论关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commerceIds}")
    @ApiOperation("删除帮养之家和评论关联")
    public AjaxResult remove(@PathVariable Long[] commerceIds)
    {
        return toAjax(commerceInfoCommentService.deleteCommerceInfoCommentByCommerceIds(commerceIds));
    }
}
